import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: null,
    token: null,
    username: 'Guest',
    isAdmin: false
  },
  mutations: {
    setToken (state, token) {
      state.token = token
    },
    getToken () {
      return this.token
    },
    setUser (state, user) {
      if (user === null) {
        user = 'Guset'
      }
      state.username = user
    },
    setAdmin (state, isAdmin) {
      state.isAdmin = isAdmin
    }
  },
  actions: {
  },
  modules: {
  }
})
